<template>
	<view class="page" :style="themeColor">
		<view class="flex benben-position-layout flex flex-wrap align-center search_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub search_fd0_0'>
				<text class='fu-iconfont2  search_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
					data-url="1">&#xE794;</text>
				<view class='flex flex-wrap align-center search_fd0_0_c1'>
					<input class='flex-sub search_fd0_0_c1_c0' type="text" :placeholder="placeholder"
						:maxlength="20" :focus="true" confirm-type="search"
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:24rpx" @confirm="jumpResultFunc()"
						v-model="keywords" />
				</view>
				<text class='fu-iconfont2  search_fd0_0_c2' @tap.stop="jumpResultFunc()">&#xE722;</text>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<!---flex布局flex布局开始-->
		<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout search_flex_1">
			<view class='flex flex-wrap align-center justify-between search_fd1_0'>
				<text class='search_fd1_0_c0'>历史搜索</text>
				<image class='search_fd1_0_c1' v-if="appSearchHistory.length > 0" :src='STATIC_URL+"67.png"' @tap.stop="popupShow1657166327458=true">
				</image>
			</view>
			<view class='flex flex-wrap align-center'>
				<view class='flex flex-wrap align-center search_fd1_1_c0' v-for="(v, k) in appSearchHistory" @tap.stop="goSearchResult(v.name)">
					<text class='search_fd1_1_c0_c0'>{{v.name}}</text>
					<image class='search_fd1_1_c0_c1' mode="aspectFit" :src='STATIC_URL+"68.png"' @tap.stop="deleteSearchFunc(v.name)"></image>
				</view>
			</view>
			<text class='search_fd1_2' v-if="appSearchHistory.length<'1'">暂无历史搜索</text>
			<!-- <text class='search_fd1_3'>推荐商品</text> -->
		</view>
		<!---flex布局flex布局结束-->
		<benben-popup v-model="popupShow1657166327458" :mask="true" mode='center'>
			<!---删除历史记录flex布局开始-->
			<view class="flex flex-direction flex-wrap align-center search_flex_2">
				<text class='search_fd2_0'>确定删除历史记录？</text>
				<view class='flex flex-wrap align-center search_fd2_1'>
					<button class='search_fd2_1_c0' @tap.stop="popupShow1657166327458=false">取消</button>
					<button class='search_fd2_1_c1' @tap.stop="clearSearchFunc()">确定</button>
				</view>
			</view>
			<!---删除历史记录flex布局结束-->
		</benben-popup>
		<!---为您推荐flex布局开始-->
		<!-- <view class="flex flex-wrap align-center benben-flex-layout search_flex_3">
			<view class='flex flex-direction flex-wrap align-stretch search_fd3_0'>
				<image class='search_fd3_0_c0' mode="scaleToFill" :src='STATIC_URL+"21.png"'></image>
				<view class='flex flex-direction flex-wrap align-stretch search_fd3_0_c1'>
					<text class='flex-sub search_fd3_0_c1_c0'>美的空调新品季 新风空调 新一级智能家</text>
					<view class='flex flex-wrap align-center'>
						<text class='search_fd3_0_c1_c1_c0'>￥</text>
						<view class=' search_fd3_0_c1_c1_c1'>
							<text class=' search_price1_fd3_0_c1_c1_c1'>{{ 999.90 | frontPrice }}</text>
							<text class=' search_price2_fd3_0_c1_c1_c1'>{{ 999.90 | laterPrice }}</text>
						</view>
					</view>
					<view class='flex flex-wrap align-center justify-between search_fd3_0_c1_c2'>
						<view class='flex flex-wrap align-center'>
							<text class='search_fd3_0_c1_c2_c0_c0'>￥</text>
							<view class=' search_fd3_0_c1_c2_c0_c1'>
								<text class=' search_price1_fd3_0_c1_c2_c0_c1'>{{ 1000 | frontPrice }}</text>
								<text class=' search_price2_fd3_0_c1_c2_c0_c1'>{{ 1000 | laterPrice }}</text>
							</view>
						</view>
						<view class='flex flex-wrap align-center'>
							<text class='search_fd3_0_c1_c2_c1_c0'>销量</text>
							<text class='search_fd3_0_c1_c2_c1_c1'>2333</text>
						</view>
					</view>
				</view>
			</view>
		</view> -->
		<!---为您推荐flex布局结束-->


	</view>
</template>
<script>
	import pagingList from '@/common/mixin/paging_list.js';
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},
		mixins: [pagingList],

		data() {
			return {
				"popupShow1657166327458": false,
				"minixPagingListsApi": "",
				"pageingListApiMethod": "",
				"allowOnloadGetList": false,
				"keywords": "",
				"dataList": [],
				"placeholder": "请输入想要搜索的的商品",
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
			appSearchHistory() { // 搜索历史
				return this.$store.state.appSearchHistory
			}
		},
		watch: {},
		onLoad(options) {
			// this.DataListFunc()
			
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			this.getSearchDefault();
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			// 获取搜索默认词   post643d18e6e62e1
			getSearchDefault() {
				this.$api.post(global.apiUrls.post643d18e6e62e1, {
					
				}).then(res => {
					if (res.data.code == 1) {
						this.placeholder = res.data.data.keyword;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			goSearchResult(keywords) {
				uni.navigateTo({
					url: '/pages/homepage/searchResult/searchResult?keyword=' + keywords
				})
			},
			
			//跳转
			jumpResultFunc() {
				if (this.keywords) {
					this.$store.commit('appSearchHistoryAdd', {
						"name": this.keywords
					})
					this.$urouter.redirectTo(`/pages/homepage/searchResult/searchResult?keyword=${this.keywords}`);
				} else {
					this.keywords = this.placeholder
					this.$store.commit('appSearchHistoryAdd', {
						"name": this.keywords
					})
					this.$urouter.redirectTo(`/pages/homepage/searchResult/searchResult?keyword=${this.keywords}`);
				}
			},
			//删除搜索记录
			deleteSearchFunc(name) {
				this.$store.commit('appSearchHistoryDel', {
					"name": name
				})

			},
			//清空搜索记录
			clearSearchFunc() {
				this.$store.commit('appSearchHistoryClean')
				this.popupShow1657166327458 = false;
				this.$message.info('已清空搜索记录')
			},
			//获取商品列表
			DataListFunc() {
				this.minixPagingListsApi = global.apiUrls.post62b9118254ebf;
				this.pageingListApiMethod = 'get';
				this.allowOnloadGetList = false;
				this.pagingListPostDataContent = {
					goods_type: '5',
					sort: '1'
				}
				this.listData = [];
				this.dataList = this.listData;
				this.pagingListToggle();
			},
			pagingListPostData() {
				return this.pagingListPostDataContent
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto !important;
	}

	.search_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.search_fd0_0_c2 {
		width: 40rpx;
		height: 40rpx;
		font-size: 36rpx;
		font-weight: 500;
	}

	.search_fd0_0_c1_c0 {
		font-size: 24rpx;
		font-weight: 400;
		color: #333;
	}

	.search_fd0_0_c1 {
		background: rgba(249, 249, 249, 1);
		background-size: 100% auto !important;
		border-radius: 34rpx 34rpx 34rpx 34rpx;
		width: 574rpx;
		height: 64rpx;
		padding: 0rpx 24rpx 0rpx 24rpx;
	}

	.search_fd0_0_c0 {
		font-size: 36rpx;
		color: #333;
		font-weight: 500;
	}

	.search_fd0_0 {
		margin: 0rpx 32rpx 0rpx 32rpx;
	}

	.search_flex_1 {
		padding: 32rpx 12rpx 12rpx 12rpx;
	}

	.search_fd1_3 {
		margin: 44rpx 12rpx 0rpx 12rpx;
		font-size: 36rpx;
		font-weight: 500;
		color: #333333;
	}

	.search_fd1_2 {
		line-height: 34rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #333333;
		margin: 24rpx 12rpx 12rpx 12rpx;
	}

	.search_fd1_1_c0_c1 {
		width: 16rpx;
		height: 16rpx;
		margin: 0rpx 0rpx 0rpx 16rpx;
	}

	.search_fd1_1_c0_c0 {
		line-height: 34rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #333333;
	}

	.search_fd1_1_c0 {
		background: #FFFFFF;
		height: 56rpx;
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		padding: 0rpx 32rpx 0rpx 32rpx;
		margin: 12rpx 12rpx 12rpx 12rpx;
	}

	.search_fd1_0_c1 {
		width: 28rpx;
		height: 28rpx;
	}

	.search_fd1_0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
	}

	.search_fd1_0 {
		margin: 0rpx 12rpx 12rpx 12rpx;
	}

	.search_flex_2 {
		background: #fff;
		margin: 0rpx 105rpx 0rpx 105rpx;
		background-size: #eee;
		border-radius: 25rpx 25rpx 25rpx 25rpx;
	}

	.search_fd2_1_c1 {
		background: transparent;
		line-height: 45rpx;
		border-radius: 0rpx 0rpx 16rpx 0rpx;
		font-size: 32rpx;
		color: rgba(59, 157, 255, 1);
		padding: 24rpx 103rpx 24rpx 99rpx;
	}

	.search_fd2_1_c0 {
		border-right: 1px solid #EEEEEE;
		background: transparent;
		line-height: 45rpx;
		border-radius: 0rpx 0rpx 0rpx 16rpx;
		font-size: 32rpx;
		color: rgba(153, 153, 153, 1);
		padding: 24rpx 103rpx 24rpx 103rpx;
	}

	.search_fd2_1 {
		border-top: 1px solid #eee;
	}

	.search_fd2_0 {
		font-size: 32rpx;
		font-weight: 400;
		line-height: 52rpx;
		color: #333333;
		margin: 56rpx 0rpx 64rpx 0rpx;
	}

	.search_flex_3 {
		padding: 0rpx 15rpx 12rpx 15rpx;
	}

	.search_fd3_0_c1_c2_c1_c1 {
		color: #BBBBBB;
		font-size: 22rpx;
		font-weight: 400;
		line-height: 30rpx;
	}

	.search_fd3_0_c1_c2_c1_c0 {
		color: #BBBBBB;
		font-size: 22rpx;
		font-weight: 400;
		line-height: 30rpx;
	}

	.search_price2_fd3_0_c1_c2_c0_c1 {
		font-size: 22rpx;
	}

	.search_price1_fd3_0_c1_c2_c0_c1 {
		font-size: 22rpx;
	}

	.search_fd3_0_c1_c2_c0_c1 {
		color: #BBBBBB;
		font-weight: 400;
		line-height: 30rpx;
		font-size: 22rpx;
		text-decoration: line-through;
	}

	.search_fd3_0_c1_c2_c0_c0 {
		color: #BBBBBB;
		font-size: 22rpx;
		font-weight: 400;
		line-height: 30rpx;
		text-decoration: line-through;
	}

	.search_fd3_0_c1_c2 {
		margin: 10rpx 0rpx 0rpx 0rpx;
	}

	.search_price2_fd3_0_c1_c1_c1 {
		font-size: 22rpx;
	}

	.search_price1_fd3_0_c1_c1_c1 {
		font-size: 32rpx;
		font-weight: 700;
		color: #FF4133;
	}

	.search_fd3_0_c1_c1_c1 {
		color: #E5393C;
		font-weight: 700;
		font-size: 36rpx;
		line-height: 48rpx;
	}

	.search_fd3_0_c1_c1_c0 {
		font-size: 22rpx;
		font-weight: 700;
		color: #FF4133;
	}

	.search_fd3_0_c1_c0 {
		-webkit-line-clamp: 2;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		font-size: 30rpx;
		font-weight: 500;
		color: #222222;
		line-height: 42rpx;
	}

	.search_fd3_0_c1 {
		margin: 24rpx 16rpx 24rpx 16rpx;
	}

	.search_fd3_0_c0 {
		width: 350rpx;
		height: 350rpx;
		border-radius: 16rpx 16rpx 0rpx 0rpx;
	}

	.search_fd3_0 {
		background: rgba(255, 255, 255, 1);
		background-size: 100% auto !important;
		margin: 10rpx 5rpx 5rpx 5rpx;
		width: 350rpx;
	}
</style>